package il.technion.ewolf.kbr.openkad.msg;

import java.util.LinkedList;

import com.google.inject.Inject;
import com.google.inject.name.Named;
//import com.sun.org.apache.xpath.internal.operations.Bool;

import il.technion.ewolf.kbr.Key;
import il.technion.ewolf.kbr.Node;
import il.technion.ewolf.kbr.openkad.msg.KadRequest;

public class ReplicationRequest extends KadRequest {

	private static final long serialVersionUID = -5126423695265512542L;

//	private String tag;
	private LinkedList<Key> objectList;
	private Boolean toReplicate;
	private Node src;
	
	@Inject
	ReplicationRequest(
			@Named("openkad.rnd.id") long id,
			@Named("openkad.local.node") Node src) {
		
		super(id, src);
		this.src = src;
	}

//	/**
//	 * Every content request has a tag associated with it.
//	 * This is the same tag given in the KeybasedRouting.sendMessage or sendRequest methods.
//	 * 
//	 * @return the message's tag
//	 */
//	public String getTag() {
//		return tag;
//	}
	
	public Node getSrcNode() {
		return src;
	}
	
	
	/**
	 * Get the key needs to be replicated
	 * @return the key
	 */
	public LinkedList<Key> getObjectList() {
		return objectList;
	}
	
	/**
	 * Sets the list of keys needs to be replicated
	 * @param list of objects keys
	 * @return the message
	 */
	public ReplicationRequest setObjectList(LinkedList<Key> objectList) {
		this.objectList = objectList;
		return this;
	}
	
	/**
	 * Gets the answer whether to replicate
	 * @return replicate or not
	 */
	public Boolean getToReplicate() {
		return toReplicate;
	}
	
	/**
	 * Sets whether to replicate the object
	 * @param to replicate or not
	 * @return the message
	 */
	public ReplicationRequest setToReplicate(Boolean toReplicate) {
		this.toReplicate = toReplicate;
		return this;
	}
	
	
//	public StoreRequest setTag(String tag) {
//		this.tag = tag;
//		return this;
//	}
	
	@Override
	public StoreResponse generateResponse(@Named("openkad.local.node") Node localNode) {
		return new StoreResponse(getId(), localNode);
	}	

}
